/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Resistenciaeletrica.java
 *
 * Created on 25/10/2011, 21:27:55
 */

package br.com.fatecpg.tp1.formularios;



/**
 *
 * @author Nelson
 */
public class Resistenciaeletrica extends javax.swing.JInternalFrame {

    /** Creates new form Resistenciaeletrica */
    public Resistenciaeletrica() {
        initComponents();
    }





    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanelValorConverter = new javax.swing.JPanel();
        jTextFieldNroConverter = new javax.swing.JTextField();
        jButtonConverter = new javax.swing.JButton();
        jPanelOpções = new javax.swing.JPanel();
        jRadioButtonNano = new javax.swing.JRadioButton();
        jRadioButtonMicro = new javax.swing.JRadioButton();
        jRadioButtonMili = new javax.swing.JRadioButton();
        jRadioButtonOhm = new javax.swing.JRadioButton();
        jRadioButtonKilo = new javax.swing.JRadioButton();
        jRadioButtonMega = new javax.swing.JRadioButton();
        jRadioButtonGiga = new javax.swing.JRadioButton();
        jRadioButtonAb = new javax.swing.JRadioButton();
        jRadioButtonVolt = new javax.swing.JRadioButton();
        jPanelResultado = new javax.swing.JPanel();
        jLabelResultado = new javax.swing.JLabel();
        jLabelGrupo = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));
        setTitle("11 - Resistência Elétrica");

        jPanelValorConverter.setBackground(new java.awt.Color(255, 255, 255));
        jPanelValorConverter.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Informe o valor a ser convertido:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 255))); // NOI18N

        jTextFieldNroConverter.setFont(new java.awt.Font("Tahoma", 0, 14));
        jTextFieldNroConverter.setForeground(new java.awt.Color(255, 0, 51));
        jTextFieldNroConverter.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextFieldNroConverter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldNroConverterActionPerformed(evt);
            }
        });

        jButtonConverter.setFont(new java.awt.Font("Tahoma", 1, 14));
        jButtonConverter.setText("Converter");
        jButtonConverter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConverterActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelValorConverterLayout = new javax.swing.GroupLayout(jPanelValorConverter);
        jPanelValorConverter.setLayout(jPanelValorConverterLayout);
        jPanelValorConverterLayout.setHorizontalGroup(
            jPanelValorConverterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelValorConverterLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelValorConverterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonConverter, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)
                    .addComponent(jTextFieldNroConverter, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanelValorConverterLayout.setVerticalGroup(
            jPanelValorConverterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelValorConverterLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextFieldNroConverter, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addComponent(jButtonConverter, javax.swing.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE)
                .addGap(25, 25, 25))
        );

        jPanelOpções.setBackground(new java.awt.Color(255, 255, 255));
        jPanelOpções.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Selecione as opções:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 255))); // NOI18N

        jRadioButtonNano.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(jRadioButtonNano);
        jRadioButtonNano.setText("Nanoohm");
        jRadioButtonNano.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonNanoActionPerformed(evt);
            }
        });

        jRadioButtonMicro.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(jRadioButtonMicro);
        jRadioButtonMicro.setText("Microohm");

        jRadioButtonMili.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(jRadioButtonMili);
        jRadioButtonMili.setText("Miliohm");

        jRadioButtonOhm.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(jRadioButtonOhm);
        jRadioButtonOhm.setText("ohm");

        jRadioButtonKilo.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(jRadioButtonKilo);
        jRadioButtonKilo.setText("Kiloohm");

        jRadioButtonMega.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(jRadioButtonMega);
        jRadioButtonMega.setText("Megaohm");

        jRadioButtonGiga.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(jRadioButtonGiga);
        jRadioButtonGiga.setText("Gigaohm");

        jRadioButtonAb.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(jRadioButtonAb);
        jRadioButtonAb.setText("Abohm");

        jRadioButtonVolt.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(jRadioButtonVolt);
        jRadioButtonVolt.setText("Volt por ampère");

        javax.swing.GroupLayout jPanelOpçõesLayout = new javax.swing.GroupLayout(jPanelOpções);
        jPanelOpções.setLayout(jPanelOpçõesLayout);
        jPanelOpçõesLayout.setHorizontalGroup(
            jPanelOpçõesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelOpçõesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelOpçõesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jRadioButtonNano)
                    .addComponent(jRadioButtonMicro)
                    .addGroup(jPanelOpçõesLayout.createSequentialGroup()
                        .addComponent(jRadioButtonMili, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
                        .addGap(48, 48, 48)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelOpçõesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jRadioButtonOhm, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jRadioButtonMega, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jRadioButtonKilo))
                .addGap(24, 24, 24)
                .addGroup(jPanelOpçõesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelOpçõesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jRadioButtonAb, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jRadioButtonGiga))
                    .addComponent(jRadioButtonVolt))
                .addContainerGap(42, Short.MAX_VALUE))
        );
        jPanelOpçõesLayout.setVerticalGroup(
            jPanelOpçõesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelOpçõesLayout.createSequentialGroup()
                .addGroup(jPanelOpçõesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelOpçõesLayout.createSequentialGroup()
                        .addGap(9, 9, 9)
                        .addComponent(jRadioButtonNano)
                        .addGap(18, 18, 18)
                        .addComponent(jRadioButtonMicro)
                        .addGap(18, 18, 18)
                        .addComponent(jRadioButtonMili))
                    .addGroup(jPanelOpçõesLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelOpçõesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelOpçõesLayout.createSequentialGroup()
                                .addComponent(jRadioButtonGiga)
                                .addGap(18, 18, 18)
                                .addComponent(jRadioButtonAb)
                                .addGap(18, 18, 18)
                                .addComponent(jRadioButtonVolt))
                            .addGroup(jPanelOpçõesLayout.createSequentialGroup()
                                .addComponent(jRadioButtonOhm)
                                .addGap(18, 18, 18)
                                .addComponent(jRadioButtonKilo)
                                .addGap(18, 18, 18)
                                .addComponent(jRadioButtonMega)))))
                .addContainerGap(10, Short.MAX_VALUE))
        );

        jPanelResultado.setBackground(new java.awt.Color(255, 255, 255));
        jPanelResultado.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Resultados:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 255))); // NOI18N

        jLabelResultado.setFont(new java.awt.Font("Tahoma", 0, 32));

        javax.swing.GroupLayout jPanelResultadoLayout = new javax.swing.GroupLayout(jPanelResultado);
        jPanelResultado.setLayout(jPanelResultadoLayout);
        jPanelResultadoLayout.setHorizontalGroup(
            jPanelResultadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelResultadoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelResultado, javax.swing.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE))
        );
        jPanelResultadoLayout.setVerticalGroup(
            jPanelResultadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelResultadoLayout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addComponent(jLabelResultado)
                .addContainerGap(68, Short.MAX_VALUE))
        );

        jLabelGrupo.setFont(new java.awt.Font("Tahoma", 0, 9)); // NOI18N
        jLabelGrupo.setForeground(new java.awt.Color(102, 102, 102));
        jLabelGrupo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelGrupo.setText("Nelson Cardoso - Thyago Santos");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanelValorConverter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(jPanelOpções, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanelResultado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelGrupo, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanelValorConverter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanelOpções, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jPanelResultado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(120, 120, 120)
                        .addComponent(jLabelGrupo))))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextFieldNroConverterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldNroConverterActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldNroConverterActionPerformed

    private void jRadioButtonNanoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonNanoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jRadioButtonNanoActionPerformed

    private void jButtonConverterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConverterActionPerformed
        // TODO add your handling code here:

//variaveis sem calculo de decimal
         long resultado;
         long valor = Long.parseLong(jTextFieldNroConverter.getText());
// variaveis com calculo de decimal
         double resultado1;
         double valor1 = Double.parseDouble(jTextFieldNroConverter.getText());
       if (jRadioButtonNano.isSelected()){
   
         resultado = valor * 1000000000;

         //converte o valor numerico para string
         jLabelResultado.setText("" + String.valueOf(resultado) + " (nΩ)");
       }

       if (jRadioButtonMicro.isSelected()){

         resultado = valor * 1000000;
         jLabelResultado.setText("" + String.valueOf(resultado) + " (µΩ)");
       }

       if (jRadioButtonMili.isSelected()){

         resultado = valor * 1000;
         jLabelResultado.setText("" + String.valueOf(resultado) + " (mΩ)");
       }

        if (jRadioButtonOhm.isSelected()){
   
         resultado = valor;
         jLabelResultado.setText("" + String.valueOf(resultado) + " (Ω)");
       }
         
        if (jRadioButtonKilo.isSelected()){
   
         resultado1 = valor1 * 0.001;
         jLabelResultado.setText("" + String.valueOf(resultado1) + " (kΩ)");
       }


        if (jRadioButtonMega.isSelected()){

         resultado1 = valor1 * 0.000001;
         jLabelResultado.setText("" + String.valueOf(resultado1) + " (MΩ)");
       }


        if (jRadioButtonGiga.isSelected()){

         resultado1 = valor1 * 0.000000001;
         jLabelResultado.setText("" + String.valueOf(resultado1) + " (GΩ)");
       }


        if (jRadioButtonAb.isSelected()){

         resultado = valor * 1000000000;
         jLabelResultado.setText("" + String.valueOf(resultado) + " (abΩ)");
       }


        if (jRadioButtonVolt.isSelected()){

         resultado1 = valor1;
         jLabelResultado.setText("" + String.valueOf(resultado1) + " (V/A)");
       }


    }//GEN-LAST:event_jButtonConverterActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButtonConverter;
    private javax.swing.JLabel jLabelGrupo;
    private javax.swing.JLabel jLabelResultado;
    private javax.swing.JPanel jPanelOpções;
    private javax.swing.JPanel jPanelResultado;
    private javax.swing.JPanel jPanelValorConverter;
    private javax.swing.JRadioButton jRadioButtonAb;
    private javax.swing.JRadioButton jRadioButtonGiga;
    private javax.swing.JRadioButton jRadioButtonKilo;
    private javax.swing.JRadioButton jRadioButtonMega;
    private javax.swing.JRadioButton jRadioButtonMicro;
    private javax.swing.JRadioButton jRadioButtonMili;
    private javax.swing.JRadioButton jRadioButtonNano;
    private javax.swing.JRadioButton jRadioButtonOhm;
    private javax.swing.JRadioButton jRadioButtonVolt;
    private javax.swing.JTextField jTextFieldNroConverter;
    // End of variables declaration//GEN-END:variables

}
